﻿namespace Marc.JwOrgClient.Model {
    using System;

    public class PodcastMagazine {
        private readonly MagazineType _type;
        private readonly DateTime _date;
        private readonly PodcastMagazineChapter[] _chapters;
        private Language _language;

        public MagazineType Type {
            get { return this._type; }
            
        }

        public DateTime Date {
            get { return this._date; } 
        }

        public string DateString {
            get { return this._type.FormatPublishedDate(this._date); } 
        }

        public PodcastMagazineChapter[] Chapters {
            get { return this._chapters; }
        }

        public Language Language {
            get { return this._language; }
        }

        public PodcastMagazine(Language language, MagazineType type, DateTime date, PodcastMagazineChapter[] chapters) {
            this._language = language;
            this._type = type;
            this._date = date;
            this._chapters = chapters;
            foreach (var chapter in chapters) {
                chapter.Magazine = this;
            }
        }

        public override string ToString() {
            return String.Format("{0} for {1:dd.MM.yyyy} with {2} chapters", this._type.Name, this._date, this._chapters.Length);
        }
    }
}